from django.db import models

# Create your models here.
#用户
class Users(models.Model):
    username = models.CharField(unique=True, max_length=32)
    name = models.CharField(max_length=32, blank=True, null=True)
    passwd = models.CharField(max_length=100)
    sex = models.IntegerField()
    address = models.CharField(max_length=300, blank=True, null=True)
    email = models.CharField(max_length=45, blank=True, null=True)
    phone = models.CharField(max_length=45)
    identity = models.IntegerField()
    viplevel = models.IntegerField(blank=True, null=True)
    registertime = models.DateTimeField()

    def toDict(self):
        return {'id':self.id,'username':self.username,'name':self.name,'sex':self.sex,'address':self.address,'email':self.email,'phone':self.phone,'identity':self.identity}

    class Meta:
        managed = False
        db_table = 'users'

#商品类别
class Goodstype(models.Model):
    name = models.CharField(max_length=45)
    pid = models.IntegerField()
    path = models.CharField(max_length=45)

    class Meta:
        managed = False
        db_table = 'goodstype'

#猫咪
class Goods(models.Model):
    typeid = models.IntegerField()
    name = models.CharField(max_length=45)
    field = models.CharField(max_length=45)
    content = models.CharField(max_length=45, blank=True, null=True)
    age = models.IntegerField()
    sex = models.IntegerField()
    clicknum = models.IntegerField(blank=True, null=True)
    picname = models.CharField(max_length=100, blank=True, null=True)
    addtime = models.DateTimeField()
    price = models.CharField(max_length=45)
    def toDict(self):
        return {'id':self.id,'typeid':self.typeid,'name':self.name,'field':self.field,'content':self.content,'age':self.age,'typename':self.typename,'sex':self.sex,'clicknum':self.clicknum}

    class Meta:
        managed = False
        db_table = 'goods'